<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.3.0: http://docutils.sourceforge.net/" />
<title>vb2Py - Code Modules</title>
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<body>
<div class="document" id="vb2py-code-modules">
<h1 class="title">vb2Py - Code Modules</h1>
<!-- filename: c:\development\python22\lib\site-packages\vb2py\doc/codemodules.htm -->
<p>Contents of this page:</p>
<ul class="simple">
<li><a class="reference" href="#general">General</a></li>
<li><a class="reference" href="#default-conversion">Default Conversion</a></li>
<li><a class="reference" href="#list-of-options">List of Options</a></li>
</ul>
<p>Options:</p>
<ul class="simple">
<li><a class="reference" href="#trytoextractdocstrings">TryToExtractDocStrings</a></li>
</ul>
<div class="section" id="general">
<h1><a name="general">General</a></h1>
<p>Code modules are translated into Python code modules with a functions and subroutines being converted to module level functions. Variables, functions and subroutines which are declared as <tt class="literal"><span class="pre">Public</span></tt> or <tt class="literal"><span class="pre">Global</span></tt> are flagged as globally accessible which means that, if another module tries to access them, then that module will acquire an <tt class="literal"><span class="pre">import</span></tt> statement to import the code module and the variable reference will be replaced by a fully qualified name (<tt class="literal"><span class="pre">module.name</span></tt>).</p>
</div>
<div class="section" id="default-conversion">
<h1><a name="default-conversion">Default Conversion</a></h1>
<table style="code-table"><tr><th class="code-header">VB</th><th class="code-header">Python</th></tr><tr><td class="vb-code-cell"><pre><br>Public Name As String<br>Public Age As Single<br>Private ID As Long<br><br>Public Sub checkAge()<br>    If Age = 0 Then Age = 1<br>End Sub<br>'<br>Private Sub setUp()<br>    ID = Rnd()<br>    If ID = 0 Then setUp<br>End Sub<br></pre></td><td class="python-code-cell"><pre><br><br>    """"""<br><br>    Name = String()<br>    Age = Single()<br>    ID = Long()<br><br>    def checkAge():<br>        global Age<br>        if Age == 0:<br>            Age = 1<br><br>    def setUp():<br>        global ID<br>        ID = Rnd()<br>        if ID == 0:<br>            setUp()<br><br></pre></td></tr></table>
</div>
<div class="section" id="list-of-options">
<h1><a name="list-of-options">List of Options</a></h1>
<p>There are no specific options relating to code modules.</p>
<p>Some <tt class="literal"><span class="pre">General</span></tt> options apply:</p>
<pre class="literal-block">
[General]
    # Yes or No, whether to try to automatically extract docstrings from the code
    TryToExtractDocStrings = Yes
</pre>
<div class="section" id="trytoextractdocstrings">
<h2><a name="trytoextractdocstrings">TryToExtractDocStrings</a></h2>
<p>Syntax: <tt class="literal"><span class="pre">TryToExtractDocStrings</span> <span class="pre">=</span> <span class="pre">Yes</span> <span class="pre">|</span> <span class="pre">No</span></tt></p>
<p>If <tt class="literal"><span class="pre">TryToExtractDocStrings</span></tt> is set then any contiguous block of comment lines found at the start of the module are interpretted as a docstring and added to the class definition. The docstring terminates with the first non-comment line.</p>
<table style="code-table"><tr><th class="code-header">VB</th><th class="code-header">Python</th></tr><tr><td class="vb-code-cell"><pre><br>' VB2PY-GlobalSet: General.TryToExtractDocStrings = Yes<br>    ' This is the documentation for the module<br>    ' This line is also documentation<br>    ' So is this one<br>    ' And this is the last<br><br>Public Name As String<br>Public Age As Single<br>Private ID As Long<br><br>Public Sub checkAge()<br>    If Age = 0 Then Age = 1<br>End Sub<br>'<br>Private Sub setUp()<br>    ID = Rnd()<br>    If ID = 0 Then setUp<br>End Sub<br>' VB2PY-Unset: General.TryToExtractDocStrings<br></pre></td><td class="python-code-cell"><pre><br><br>    """ This is the documentation for the module<br>     This line is also documentation<br>     So is this one<br>     And this is the last<br>    <br>    """<br><br>    Name = String()<br>    Age = Single()<br>    ID = Long()<br><br>    def checkAge():<br>        global Age<br>        if Age == 0:<br>            Age = 1<br><br>    def setUp():<br>        global ID<br>        ID = Rnd()<br>        if ID == 0:<br>            setUp()<br><br></pre></td></tr></table>
</div>
</div>
</div>
</body>
</html>
